/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import ts from '~/vendor/ohos-typescript';

import { NodePredicate } from '~/type/Predicate';

/**
 * @category AST Type
 */
export const ArrayLiteralExpression: NodePredicate<ts.ArrayLiteralExpression> = {
    is(node: ts.Node): node is ts.ArrayLiteralExpression {
        return ts.isArrayLiteralExpression(node);
    },
};

/**
 * @category AST Type
 */
export const ObjectLiteralExpression: NodePredicate<ts.ObjectLiteralExpression> = {
    is(node: ts.Node): node is ts.ObjectLiteralExpression {
        return ts.isObjectLiteralExpression(node);
    },
};

/**
 * @category AST Type
 */
export const PropertyAccessExpression: NodePredicate<ts.PropertyAccessExpression> = {
    is(node: ts.Node): node is ts.PropertyAccessExpression {
        return ts.isPropertyAccessExpression(node);
    },
};

/**
 * @category AST Type
 */
export const ElementAccessExpression: NodePredicate<ts.ElementAccessExpression> = {
    is(node: ts.Node): node is ts.ElementAccessExpression {
        return ts.isElementAccessExpression(node);
    },
};

/**
 * @category AST Type
 */
export const CallExpression: NodePredicate<ts.CallExpression> = {
    is(node: ts.Node): node is ts.CallExpression {
        return ts.isCallExpression(node);
    },
};

/**
 * @category AST Type
 */
export const NewExpression: NodePredicate<ts.NewExpression> = {
    is(node: ts.Node): node is ts.NewExpression {
        return ts.isNewExpression(node);
    },
};

/**
 * @category AST Type
 */
export const FunctionExpression: NodePredicate<ts.FunctionExpression> = {
    is(node: ts.Node): node is ts.FunctionExpression {
        return ts.isFunctionExpression(node);
    },
};

/**
 * @category AST Type
 */
export const ArrowFunction: NodePredicate<ts.ArrowFunction> = {
    is(node: ts.Node): node is ts.ArrowFunction {
        return ts.isArrowFunction(node);
    },
};

/**
 * @category AST Type
 */
export const DeleteExpression: NodePredicate<ts.DeleteExpression> = {
    is(node: ts.Node): node is ts.DeleteExpression {
        return ts.isDeleteExpression(node);
    },
};

/**
 * @category AST Type
 */
export const TypeOfExpression: NodePredicate<ts.TypeOfExpression> = {
    is(node: ts.Node): node is ts.TypeOfExpression {
        return ts.isTypeOfExpression(node);
    },
};

/**
 * @category AST Type
 */
export const VoidExpression: NodePredicate<ts.VoidExpression> = {
    is(node: ts.Node): node is ts.VoidExpression {
        return ts.isVoidExpression(node);
    },
};

/**
 * @category AST Type
 */
export const AwaitExpression: NodePredicate<ts.AwaitExpression> = {
    is(node: ts.Node): node is ts.AwaitExpression {
        return ts.isAwaitExpression(node);
    },
};

/**
 * @category AST Type
 */
export const PrefixUnaryExpression: NodePredicate<ts.PrefixUnaryExpression> = {
    is(node: ts.Node): node is ts.PrefixUnaryExpression {
        return ts.isPrefixUnaryExpression(node);
    },
};

/**
 * @category AST Type
 */
export const PostfixUnaryExpression: NodePredicate<ts.PostfixUnaryExpression> = {
    is(node: ts.Node): node is ts.PostfixUnaryExpression {
        return ts.isPostfixUnaryExpression(node);
    },
};

/**
 * @category AST Type
 */
export const BinaryExpression: NodePredicate<ts.BinaryExpression> = {
    is(node: ts.Node): node is ts.BinaryExpression {
        return ts.isBinaryExpression(node);
    },
};

/**
 * @category AST Type
 */
export const ConditionalExpression: NodePredicate<ts.ConditionalExpression> = {
    is(node: ts.Node): node is ts.ConditionalExpression {
        return ts.isConditionalExpression(node);
    },
};

/**
 * @category AST Type
 */
export const AsExpression: NodePredicate<ts.AsExpression> = {
    is(node: ts.Node): node is ts.AsExpression {
        return ts.isAsExpression(node);
    },
};
